var app = getApp(), util = require("../../../resource/js/util.js"), $ = require("../../../resource/utils/underscore"), WxParse = require("../../../resource/wxParse/wxParse.js"), _function = require("../../../resource/function/function.js");

Page({
    data: {
        datum: [],
        total: 0,
        userInfo: [],
        types: 0,
        ismore: !0,
        p: 1,
        pnum: 6
    },
    onLoad: function(t) {
        _function.system(this), 1 == t.types ? wx.setNavigationBarTitle({
            title: "我的课程"
        }) : 2 == t.types ? wx.setNavigationBarTitle({
            title: "已购买课程"
        }) : 3 == t.types && wx.setNavigationBarTitle({
            title: "我的收藏"
        });
        var e = wx.getStorageSync("userInfo");
        this.setData({
            userInfo: e,
            types: t.types
        }), this.getDatum();
    },
    getDatum: function() {
        var a = this;
        1 == this.data.ismore ? _function.request("entry/wxapp/UserArticle", {
            p: this.data.p,
            pnum: this.data.pnum,
            types: this.data.types,
            openid: this.data.userInfo.openid,
            author_id: this.data.userInfo.author
        }, "", function(t) {
            var e = a.data.datum;
            e = 1 == a.data.p ? t.data || [] : e.concat(t.data || []), a.setData({
                datum: e,
                total: t.total,
                ismore: e.length != a.data.total
            });
        }, this) : _function.hint(1, "没有更多啦^_^!", 2e3, function(t) {});
    },
    detail: function(t) {
        var e = t.currentTarget.dataset.id, a = t.currentTarget.dataset.url;
        null == t.currentTarget.dataset.title ? _function.request("entry/wxapp/Judge", {
            uid: this.data.userInfo.id,
            id: e
        }, "", function(t) {
            0 == t ? _function.hint(3, "抱歉,该课程仅限指定分组用户阅览^_^!", "温馨提示", function(t) {}) : wx.navigateTo({
                url: a + "?id=" + e
            });
        }, this) : wx.navigateTo({
            url: "../../newcms/column/column?id=" + e
        });
    },
    linkto: function(t) {
        wx.navigateTo({
            url: "../user_publish/index?id=" + t.currentTarget.dataset.id
        });
    },
    onReachBottom: function() {
        this.setData({
            p: parseInt(this.data.p) + 1
        }), this.getDatum();
    },
    onPullDownRefresh: function() {
        _function.system(this), 1 == this.data.types ? wx.setNavigationBarTitle({
            title: "我的课程"
        }) : 2 == this.data.types ? wx.setNavigationBarTitle({
            title: "已购买课程"
        }) : 3 == this.data.types && wx.setNavigationBarTitle({
            title: "我的收藏"
        }), this.getDatum(), wx.stopPullDownRefresh();
    }
});